<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>修改密码</title>
		 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
         <meta name="apple-mobile-web-app-capable" content="yes">
         <meta content="yes" name="apple-touch-fullscreen">
         <meta name="apple-mobile-web-app-status-bar-style" content="black">
         <script src="js/add_js.js"></script>
	</head>
	<body>
		<!--nav-->
        <nav class="bar bar-tab">
             <a class="tab-item external active" href="home.html">我的</a>
             <a class="tab-item external" href="order.html">定单</a>
             <a class="tab-item external" href="carRental.html">发布</a>
             <a class="tab-item external" href="rentalCar.html">租用</a>
             <div class="clear"></div>
        </nav>
        <!--nav-->
		<div class="page content">
			<header class="bar bar-nav">
               
               <a  class="button button-link button-nav pull-right active">设置登陆密码</a>
               <a href="changePass.html" class="button button-link button-nav pull-right">返回 </a>
            </header>
      		<div class="login-list">
      			<ul>
      			    <li><input class="c-border login-list-mm" type="password" placeholder="登陆密码" name="u_password"> </li>
      			    <li><input class="c-border login-list-qr" type="password" placeholder="确认登陆密码"> </li> 
      			    <li class="login-list-b"><a class="bottn changPass-btn-submit" id="zc" style="float: right;">确认</a><div class="clear"></div></li>
      			  
      			 </ul>
      	    </div>
      	<script>
     
      		$(document).ready(function(){
      			if(my.checkLogin()){
      				my.scollToggleBar()
      			//my.checkLogin()
      			//key=my.get_key(sessionStorage.token)
      			key=my.get_key(my.getCookie('token'))
      			//表单选中效果切换
//    			$('.login-list input').focus(function(){
//    				$(this).css('color','#fff')
//    			})
//    			$('.login-list input').blur(function(){
//    				$(this).css('color','#5926BF')
//    			})
      			//验证两次密码输入
      			$('.login-list-qr').blur(function(){
      					if($(this).val()!=$('.login-list-mm').val()){
      						$(this).val('')
      						$.toast('两次输入密码不相同')
      					}
      					
      				}
      			)
      			//提交
      			$('.changPass-btn-submit').click(function(){
      				if($('.login-list input:eq(0)').val().length<6||$('.login-list input:eq(1)').val()<6){
      					$.toast('输入有误，请重新输入')
      					$('.login-list input:eq(0)').val('').focus()
      					return false
      				}
      				if($('.login-list-qr').val()!=$('.login-list-mm').val()){
      						$(this).val('')
      						$.toast('两次输入密码不相同')
      					return false
      					}
      				$.showIndicator()
      				$(this).css({'color':'#fff','backgroundColor':'#5926BF'})
      				var info={
      						//'u_userid':sessionStorage.id,
      						'u_userid':my.getCookie('id'),
      						'u_password':$('[name=u_password]').val(),

      					}
    					info=JSON.stringify(info)
                        info=my.cryptoASEencrypt(info,key).toString()
      				$.ajax({
      						type:"post",
      						url:"http://192.168.1.10:8082/index.php?r=userabout%2Fuser%2Fuserupdatepassword",
      						data:{
      							'api_value':info
      						},
      						async:true,
      						error:function(){
      							$.hideIndicator()
      							$.toast("修改失败，请重试..");
      						},
      						success:function(data){
      							if(data.match("err_code")!=null){
      								$.hideIndicator()
      								switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									    my.tokenExpire()
      									   break;
      									default:
      									   $.toast(JSON.parse(data).err_msg);
      									   $.router.reloadPage()
      								}
                                         
      							}else{
      								    data=JSON.parse(my.cryptoASEdencrypt(data,key))
      								    $.hideIndicator()
      								    if(data.result_state!='ok'){
      								    	  $.alert("修改失败，请您重试",function(){
      								    	  	$.router.reloadPage()
      								    	  });
      								    	  
      								    }else{
      								        $.alert("修改成功",function(){
      								           $.router.loadPage("home.html");	
      								        });
      							            
      								    }
      								    
      								   
      							}
      						},
      				});
      						
      			})
      			}
      		})
      	</script>
      </div>
	</body>
</html>

